import { defineStore } from 'pinia';

export const dataSetStore = defineStore('dataStore', {
  state: () => ({
    createDataSetObj: {},
    dataset_id: 0,
    task_id: 0,//标注界面的id
    versionData: '',
    fileTypeStore: '',
    labelUseData:{
      id:0,
      annotation_config:'',
      data_type:'',
      title:''
    },
    labelsArr:<any>[],
    feature_id:0,
    pageData:{
      page:1,
      page_size: 10
    },
    loginDialog: false,
    chooseNumber: '1',
    dataSetType: 'all',
    isQuickStart:true,
    quickStart:<any>{
      tipsPopup:false,
      quickFlow:false,
      flowNumber:0,
      detailFlow:1
    },
    quickModelTitle:<any>{
      title:'',
      id:0
    }
  }),
  getters: {
  },
  actions: {
    chooseNumberSet(str:string){
      this.chooseNumber = str;
    },
    setobj(obj: object) {
      this.createDataSetObj = obj
    },
    setDataSetType(str:string){
      this.dataSetType = str;
    },
    versionset(str:string){
      this.versionData = str
    },
    taskId(num: number) {
      this.task_id = num
    },
    dataset(num: number) {
      this.dataset_id = num
    },
    fileType(str: string) {
      this.fileTypeStore = str
    },
    setUseData(id:number,config:string,type:string,titleStr:string){
        this.labelUseData = {
          id:id,
          annotation_config:config,
          data_type:type,
          title:titleStr
        }
    },
    setLabelsArr(arr:Array<any>){
      this.labelsArr=arr
    },
    setFeature(num:number){
      this.feature_id=num
    },
    setPageSizeData(num:number){
      this.pageData.page_size=num
    },
    setPageData(num:number){
      this.pageData.page=num
    },
    setLoginDialog(booleanValue:boolean){
      this.loginDialog =  booleanValue
    },
    setIsQuickStart(state:boolean){
      this.isQuickStart=state
    },
    setQuickStart(obj:object){
      this.quickStart=obj
    },
    setQuickModelTitle(obj:object){
      this.quickModelTitle=obj
    }
  },
  persist: {
    enabled: true, //不单独设置则为默认全开
    strategies: [
      {
        // 自定义存储方式，默认sessionStorage
        storage: sessionStorage,
        // 指定要持久化的数据
        paths: ['dataset_id','task_id', 'versionData', 'loginDialog', 'fileType', 'createDataSetObj','labelUseData','labelsArr','feature_id','pageData','quickStart','isQuickStart','quickModelTitle']
      }
    ]
  }
});
